package com.xuhao.examai.question.infrastructure.persistence;

import com.xuhao.examai.question.domain.models.Question;
import com.xuhao.examai.question.domain.repositories.QuestionRepository;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Optional;

@Repository
@RequiredArgsConstructor
public class QuestionRepositoryImpl implements QuestionRepository {

	private final QuestionJpaRepository questionJpaRepository;

	@Override
	public Question save(Question question) {
		return questionJpaRepository.save(question);
	}

	@Override
	public Optional<Question> findById(Long id) {
		return questionJpaRepository.findById(id);
	}

	@Override
	public List<Question> findByExamId(Long examId) {
		return questionJpaRepository.findByExamId(examId);
	}

	@Override
	public List<Question> findByKnowledgePoint(String knowledgePoint) {
		return questionJpaRepository.findByKnowledgePoint(knowledgePoint);
	}

	@Override
	public List<Question> findByDifficulty(String difficulty) {
		return questionJpaRepository.findByDifficulty(difficulty);
	}

	@Override
	public List<Question> findByQuestionType(String questionType) {
		return questionJpaRepository.findByQuestionType(questionType);
	}

	@Override
	public void deleteById(Long id) {
		questionJpaRepository.deleteById(id);
	}

	@Override
	public boolean existsById(Long id) {
		return questionJpaRepository.existsById(id);
	}
}